﻿
namespace TinyMceWrapper.Web.Configuration
{

    #region [ Imports ]

    using System.Configuration;
    using System.Globalization;

    #endregion

    internal static class ConfigUtil
    {

        #region [ Public Static Properties ]

        public static TinyMceSection TinyMce
        {
            get { return GetSection<TinyMceSection>("tinymce"); }
        }

        #endregion

        #region [ Public Static Methods ]

        public static TSection GetSection<TSection>(string sectionName)
        {
            object section = ConfigurationManager.GetSection(sectionName);

            if (section == null || !(section is TSection))
                throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, Strings.ConfigUtil_unable_to_get_section, sectionName));

            return (TSection)section;
        }

        #endregion

    }

}
